package com.aco.party.service.system;

import com.aco.party.dao.custom.PermissionDao;
import com.aco.party.model.po.Permission;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class PermissionService {

	@Resource
	private PermissionDao permissionDao;
	
	public void addPermission(Permission permission) {
		permissionDao.insertSelective(permission);
	}

	public void updatePermission(Permission permission) {
		permissionDao.updateByPrimaryKey(permission);
	}

	public void deletePermission(Long permissionId) {
		permissionDao.deleteByPrimaryKey(permissionId);
	}

	public List<Permission> findAllPermissions() {
		return permissionDao.getAll();
	}

	public Permission getPermission(Long permissionId) {
		return permissionDao.selectByPrimaryKey(permissionId);
	}

	public List<Permission> getPermissionsByRoleId(Long roleId){
		return permissionDao.getPermissionsByRoleId(roleId);
	}

}
